package com.sicaolong.eventdefine.model.impl;

import com.sicaolong.eventdefine.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("scl.local.receiver")
public class LocalReceiver implements Receiver {
    private static final Logger logger = LoggerFactory.getLogger(LocalSender.class);

    @Override
    public void handle(Event event) {
        //省略线程池
        String type = event.getType();
        logger.warn("[localReceiver] 开始消费事件--[{}]", type);
        EventTemplate eventTemplate = EventDefManager.getInstance().getEventTemplate(type);
        List<EventProcess> eventProcessList = eventTemplate.getEventProcessList();
        for (EventProcess eventProcess : eventProcessList) {
            eventProcess.handle();
        }
    }
}
